
import type { InjectionKey } from 'vue'
import { watch } from 'vue'
import { defineStore, useStoreLocal } from '@naturefw/nf-state'
import type { IState } from '@naturefw/nf-state/dist/type'

const flag = Symbol('pager') as InjectionKey<string>

import metaForm from './travel-form.json'
import metaList from './travel-list.json'

/**
 * 注册差旅费用的 meta
 * @returns
 */
export const regTravelMeta = (): IState => {
  // 定义 列表用的状态
  const state = defineStore(flag, {
    state: () => {
      return {
        metaForm,
        metaList
      }
    },
    getters: {
    },
    actions: {
     
    }
  },
  { isLocal: true }
  )
  
  return state
}


/**
 * 子组件用 inject 获取状态 
 * @returns
 */
export const getTravelMeta = (): IState => {
  return useStoreLocal<IState>(flag)
}